    //登录界面弹出

        $(document).click(function () {
            $("#click_login").hide();
        });
        $("#click_login").click(function (event) {
            event.stopPropagation();
        });
        $(".login").click(function (event) {
            event.stopPropagation();
            $("#click_login").toggle();
            setTimeout(function(){
            try{
                $('.text_phone').focus();
            }
            catch(e){}
        },100);
        });
        $('.text_phone').focus(function(){
            $(".notices").html("");
        });
        $('.pass').focus(function(){
            $(".notices").html("");
        });
        $(".buy").mouseover(function () {
            $("#click_login").hide();
        });


    $(function(){
        var navbar = function(o){            
            var f = $("." + o.f), s = f.children("." + o.s), width = f.width();
            f.hover(function(){
                s.css("display", "block");
                },function(){
                s.css("display", "none");  
            });
        }
        navbar({
            f:"buy",
            s:"buy_shop"
        });
        navbar({
            f:"inactive",
            s:"inactives"
        });
        navbar({
            f:"main_header_right",
            s:"sort-order"
        });
    }); 
 
  $(function(){
    var slideMenu=function(o){
        var winWidth = $(window).width();
        var f=$("."+o.f),s=f.children("#"+o.s),h=s.outerHeight(),left=f.position().left;                   
        f.css({position:"relative"});
        s.css({height:0,opacity:0,left:-left,width:winWidth});
        f.hover(function(){
        s.show().stop(true,false).animate({height:h,opacity:0.8},350,function(){
                s.css({overflow:"visible"});
        });
        },function(){
                s.stop(true,false).animate({height:0,opacity:0},350,function(){
                        s.hide();
                });
        });
    }
    //网站导航下拉框
    slideMenu({
            f:"matong",
            s:"goods"
    });
    });

  $(function(){
    var slideMenu=function(o){        
        var f=$("."+o.f),s=f.children("."+o.s),h=s.outerHeight();
        f.css({position:"relative"});
        s.css({height:0,opacity:0});
        f.hover(function(){
        s.show().stop(true,false).animate({height:h,opacity:1},350,function(){
                s.css({overflow:"visible"});
        });
        },function(){
                s.stop(true,false).animate({height:0,opacity:0},350,function(){
                        s.hide();
                });
        });
    }
    //个人账户下拉
    slideMenu({
            f:"login_n",
            s:"mybag"
    });
    });


//点击登录class为tc 显示
function openDi(item){
    var storage = window.localStorage;
    if(storage){
        storage.setItem("goods_id",JSON.stringify(item));
    }     
    $("#gray").show();
    $("#popup").fadeIn();//查找ID为popup的DIV show()显示#gray
    tc_center(); 
}

//点击关闭按钮
$("a.guanbi").click(function(){
	$("#gray").fadeOut();
	$("#popup").fadeOut();//查找ID为popup的DIV hide()隐藏
});

$("#gray").click(function(){
    $("#gray").fadeOut();
    $("#popup").fadeOut();//查找ID为popup的DIV hide()隐藏
});

//窗口水平居中
$(window).resize(function(){
	tc_center();
});

function tc_center(){
    var scrollPo;
    if (typeof window.pageYOffset != 'undefined') 
    { 
      scrollPo = window.pageYOffset;
    } 
    else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') 
    { 
      scrollPo = document.documentElement.scrollTop; 
    }
    else if (typeof document.body != 'undefined') 
    {
      scrollPo = document.body.scrollTop;
    }
    var _top = (parseInt(scrollPo + 280)) + "px";
    var _left = (parseInt(document.body.offsetWidth)-580) / 2 + "px"; // 屏幕居中
	
	$(".popup").css({top:_top,left:_left});
};


//ajax登录
  function signIn(){
        var frm = document.forms['ECS_LOGINFORM'];
        if (frm)
        {
            var username = frm.elements['username'].value;
            var password = frm.elements['password'].value;
            var captcha = '';           
            if (frm.elements['captcha'])
            {
              captcha = frm.elements['captcha'].value;
            }

            if (username.length == 0 || password.length == 0)
            {     
                $(".notices").html("用户名和密码不能为空");
                return;
            }
            else
            {
               Ajax.call('user.php?act=signin', 'username=' + username + '&password=' + encodeURIComponent(password) + '&captcha=' + captcha, signinResponse, "POST", "TEXT");
            }
        }
        else
        {
            $(".notices").html("Template error!");
        }
    }

    function signinResponse(result)
    {
        var userName = document.forms['ECS_LOGINFORM'].elements['username'].value;
        
        var res   = result.parseJSON();
        if (res.error > 0)
        {
            $(".notices").html(res.content);
            if(res.html)
            {
                var mzone = document.getElementById("ECS_MEMBERZONE");
                document.forms['ECS_LOGINFORM'].elements['username'].value = userName;
            }
        }
        else
        {
            if (mzone)
            {
                mzone.innerHTML = res.html;
                evalscript(res.ucdata);
               //alert(res.ucdata);
            }
            else
            {
               window.location.reload();
            }
        }
    }  
        
//SmoothScroll  平滑滚动 app
$(document).ready(function() {
    //css3 and animation
    var elmArr = [],
     $win = $(window);
     $(".window").each(function(i,elm){
        $(elm).data("higher",$(elm).offset().top);
        elmArr.push(elm);
     });
     dealClass();             
     $win.scroll(function(){
         dealClass();
     });
    function dealClass(){
        var top = $win.height() + $win.scrollTop();        
        for(var i = 0,$elem; i < elmArr.length; i++){
            $elem = $(elmArr[i]);
            if($elem.data("higher")+350 <= top){
                    $elem.addClass("visible");  
                    elmArr.splice(i, 1);                      
            }else{
                    $elem.removeClass("visible");
            }
        }
     }

    //SmoothScroll
    $('a[href*="#"]:not([href="#"])').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var target = $(this.hash);
            target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
            if (target.length) {
                $('html, body').animate({
                    scrollTop: target.offset().top
                }, 1000);
                return false;
            }
        }
    });

});


//searchbar
    $('.sp3').click(function(e){
        var clientH = $(document).height();         
        e.preventDefault();
        $('body').addClass('active');
        setTimeout(function(){
            try{
                $('.txt').focus();
            }
            catch(e){}
        },1000)
        $('.search-layer').css({'height':clientH});
    });
    $('.search-layer').click(function(e){
        e.preventDefault();
        $('body').removeClass('active');
     });
    $('.search-close').click(function(e){
        e.preventDefault();
        $('body').removeClass('active');
    });



